【记录】JAVA8 Stream()遍历求某列总和 | 您所在的位置:网站首页 › stream string求和 › 【记录】JAVA8 Stream()遍历求某列总和 |
List commonList; // 取字段string转int构建新列表List collect = commonList.stream().map(dto -> Integer.valueOf(dto.getCell6())).collect(Collectors.toList()); // reduce求和 Optional reduce = collect.stream().reduce(Integer::sum); Integer total = reduce.get();
参考地址 JDK 1.8 新特性之Stream 详解个人笔记:https://blog.csdn.net/chenhao_c_h/article/details/80691284 实现一个LIST集合中的某个元素的求和: https://www.cnblogs.com/jishumonkey/p/12166541.html Java8对List的求和:https://blog.csdn.net/hsz2568952354/article/details/89886743 |
CopyRight 2018-2019 实验室设备网 版权所有 |